import axios from '@/libs/api.request'
import {getFullUrl} from '../config'

let getUrl = getFullUrl('user')

//--------------------------------------GET
// 获取所有项目类型
export const listNews = () => {
  return axios.request({
    url: getUrl('/news'),
    method: 'GET'
  })
}


// 获取所有项目类型
export const getNews = (newsId) => {
  return axios.request({
    url: getUrl('/news/' + newsId),
    method: 'GET'
  })
}


//--------------------------------------POST

// 添加项目类型
export const addNews = (news) => {
  return axios.request({
    url: getUrl('/news'),
    method: 'POST',
    data: news
  })
}


//--------------------------------------PATCH

// 更新项目类型
export const updateNews = (news) => {
  return axios.request({
    url: getUrl('/news'),
    method: 'PUT',
    data: news
  })
}

// 更新投保人
export const updateSequence= (news) => {
  return axios.request({
    url: getUrl('/news'),
    method: 'PATCH',
    data: {
      id: news.id,
      sequence: news.sequence
    }
  })
}
//--------------------------------------DELETE

// 删除项目类型
export const removeNews = (newsId) => {
  return axios.request({
    url: getUrl('/news/' + newsId),
    method: 'DELETE'
  })
}
